package com.ctl.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * <p>Title: MathUtil</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2019</p>
 * <p>Company: www.ctl.com</p>
 *
 * @author ctl
 * @version 1.1
 * @date 2022-07-05 17:42
 */
public class MathUtil {
    private static Logger logger = LoggerFactory.getLogger(MathUtil.class);

    public static void main(String[] args) {
        //        圆点坐标：(x0,y0) 半径：r 角度：a0
//        则圆上任一点为：（x1,y1）
        double x0 = 12510;
        double y0 = 9260;
        int radius=10;//半径
        System.out.println( getPoint(x0,y0,radius,30));
    }

    /**
     * 圆点坐标：(x0,y0) 半径：radius 角度：angle
     * 则圆上任一点为：（x1,y1）
     * @param x0
     * @param y0
     * @param radius
     * @param angle
     * @return
     */
    private static Object getPoint(double x0, double y0, int radius, int angle) {
        logger.info(" x0={}, y0={}, radius={}, angle={}",x0, y0, radius, angle);
        Double x1 = x0 + radius * Math.cos(Math.toRadians(angle));
        Double y1 = y0 + radius * Math.sin(Math.toRadians(angle));
        logger.info("x1={},y1={}",x1, y1);
        return new Point().withX(x1).withY(y1);
    }
    static class Point {
        private Double x;
        private Double y;

        public Double getX() {
            return x;
        }

        public void setX(Double x) {
            this.x = x;
        }

        public Double getY() {
            return y;
        }

        public void setY(Double y) {
            this.y = y;
        }

        public Point withX(Double x) {
            this.x = x;
            return this;
        }

        public Point withY(Double y) {
            this.y = y;
            return this;
        }

        @Override
        public String toString() {
            return "Point{" +
                    "x=" + x +
                    ", y=" + y +
                    '}';
        }
    }
}
